package Euler58;

import ReusableCode.*;

public class SpiralPrimes {
	public static void main(String[] args) {
		int max = Integer.MAX_VALUE, counter = 1, adder = 3, diags=0, prims = 0;
		double percent = 1.0;
		
		while((percent>=0.1 || counter<=49) && counter<=max)
		{
			if(counter == adder*adder)
			{
				adder +=2;
			}
			
			if(PrimeFunctions.isPrime(counter))
			{
				prims++;
			}
			if(counter > 1){
				diags++;
			}
			
			percent = ((double)prims/diags);
			counter += adder - 1;
		}
		
		System.out.println(percent);
		
		if(counter==adder*adder)
		{
			System.out.println("Side length is: " + adder);
		}
		else
		{
			System.out.println("Side length is: " + (adder-2));
		}
	}
}